#Region "using directives"

Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports System.Collections.Generic
Imports System.Drawing
Imports System
Imports C4F.DevKit.Speech
#End Region

Namespace SpeechApplication
	Public Partial Class SpeechGUI
		Inherits Form

		#Region "Constructors"

		Public Sub New()
			InitializeComponent()
		End Sub

		#End Region

		#Region "Event Handlers"

		Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			Me.Close()
		End Sub

		Private Sub tabcontrol_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tabcontrol.SelectedIndexChanged
			Dim instantiationSuccessful As Boolean = False
			Try
				Select Case tabcontrol.SelectedIndex
					Case 0
						sapiManager1.StopSpeechRecognitionEngine()
						sapiManager1.StopDictationEngine()
					Case 1
						Try
							instantiationSuccessful = sapiManager1.InitializeDictationEngine(Nothing)
						Catch
							Throw New Exception("Dictation grammer may not be supported on your machine.")
						End Try

						If instantiationSuccessful Then
							sapiManager1.StopSpeechRecognitionEngine()
							sapiManager1.StartDictationEngine()
						End If
				End Select
			Catch ex As Exception
				MessageBox.Show(ex.Message, "SpeechGUI", MessageBoxButtons.OK, MessageBoxIcon.Error)
			End Try
		End Sub

		Private Sub lnkSettings_LinkClicked(ByVal sender As Object, ByVal e As LinkLabelLinkClickedEventArgs) Handles lnkSettings.LinkClicked
			Dim form As SpeechSettings = New SpeechSettings(Me.sapiManager1)
			form.ShowDialog()
		End Sub

		#End Region 

	End Class
End Namespace